<template>
  <header class="header">
    <h1>todos</h1>
    <input id="toggle-all" class="toggle-all" type="checkbox" v-model="isAll">
    <label for="toggle-all"></label>
    <input
      class="new-todo"
      placeholder="输入任务名称-回车确认"
      v-model="$store.state.todoMain.itemVal"
     @change="addTodoLiST"
      autofocus
    />
  </header>
</template>

<script>
import {mapMutations} from "vuex"
export default {
  name:"TodoHeader",
  data(){
    return {
      itemVal:""
    }
  },
  computed:{
    isAll:{
      set(val){
        console.log(444444444)
       this.$store.state.todoMain.todiList.forEach((item)=>{
        item.idDone=val
       })
      },
      get(){
        console.log(55555555)
        return this.$store.state.todoMain.todiList.every((item)=>{
          return item.idDone
        })
      }
    }
  },
  methods:{
    ...mapMutations("todoMain",["addTodoLiST"])
  }
}
</script>
